/*
 *  dbexpinf.cpp - Informix dbExpress driver Win32 DLL entry point
 *
 *    Copyright (c) 2001-2006, Luxena Software Company. All rights reserved.
 *
 *  Purpose:
 *
 */

#include <windows.h>
#include <ifxvariable.hpp>

ifx_var_freevar_proc g_ifx_var_freevar = 0;
HMODULE handleInformixClientDLL;

BOOL APIENTRY DllMain(HANDLE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved)
{
	switch (ul_reason_for_call)
	{
		case DLL_PROCESS_ATTACH:
			{
				handleInformixClientDLL = LoadLibrary("isqlt09a.dll");
				if (handleInformixClientDLL != INVALID_HANDLE_VALUE) {
					g_ifx_var_freevar = reinterpret_cast<ifx_var_freevar_proc>(
						GetProcAddress(handleInformixClientDLL, "ifx_var_freevar"));
				}
			} break;
		case DLL_PROCESS_DETACH:
			{
				if (handleInformixClientDLL != INVALID_HANDLE_VALUE)
					FreeLibrary(handleInformixClientDLL);
			} break;
	}
	return TRUE;
}
